package demo4;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 何华树
 * Date: 2024-09-06
 * Time: 10:41
 */
class Num {
    public int num;
}
public class SwapTest {
    public static void Swap(Num val1,Num val2) {
        int tmp = val1.num;
        val1.num = val2.num;
        val2.num = tmp;
    }
    public static void main(String[] args) {
        Num n1 = new Num();
        Num n2 = new Num();
        n1.num = 10;
        n2.num = 20;
        System.out.println("交换之前： "+n1.num+" "+n2.num);
        Swap(n1,n2);
        System.out.println("交换之后： "+n1.num+" "+n2.num);
    }
}
